package com.guofen.service.sjq.impl;

import com.guofen.dao.SjqWeightProductionFaecesMapper;
import com.guofen.dao.SjqWeightProductionKitchenMapper;
import com.guofen.pojo.SjqWaterProductionDeliverWater;
import com.guofen.pojo.SjqWeightProductionFaeces;
import com.guofen.pojo.SjqWeightProductionKitchen;
import com.guofen.service.sjq.SjqWeightProductionService;
import com.guofen.util.DateAndTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SjqWeightProductionServiceImpl implements SjqWeightProductionService {

    @Autowired
    SjqWeightProductionFaecesMapper sjqWeightProductionFaecesMapper;

    @Autowired
    SjqWeightProductionKitchenMapper sjqWeightProductionKitchenMapper;

    @Override
    public boolean addFormFaeces(String date,String startTime,String closeTime,String softNormal,String monitorNormal,String dataNormal,
                          String connectNormal,int train1,double weight1,int train2,double weight2,int train3,
                          double weight3,int train4,double weight4,int trainTotal,double weightTotal,int trainResidue,
                          double weightResidue,String operator,String note){
        //        String date = DateAndTimeUtil.getDate();
        SjqWeightProductionFaeces  sjqWeightProductionFaeces = new SjqWeightProductionFaeces();
        sjqWeightProductionFaeces.setDate(date);
        sjqWeightProductionFaeces.setStartTime(startTime);
        sjqWeightProductionFaeces.setCloseTime(closeTime);
        sjqWeightProductionFaeces.setSoftNormal(softNormal);
        sjqWeightProductionFaeces.setMonitorNormal(monitorNormal);
        sjqWeightProductionFaeces.setDataNormal(dataNormal);
        sjqWeightProductionFaeces.setConnectNormal(connectNormal);
        sjqWeightProductionFaeces.setTrain1(train1);
        sjqWeightProductionFaeces.setWeight1(weight1);
        sjqWeightProductionFaeces.setTrain2(train2);
        sjqWeightProductionFaeces.setWeight2(weight2);
        sjqWeightProductionFaeces.setTrain3(train3);
        sjqWeightProductionFaeces.setWeight3(weight3);
        sjqWeightProductionFaeces.setTrain4(train4);
        sjqWeightProductionFaeces.setWeight4(weight4);
        sjqWeightProductionFaeces.setTrainTotal(trainTotal);
        sjqWeightProductionFaeces.setWeightTotal(weightTotal);
        sjqWeightProductionFaeces.setTrainResidue(trainResidue);
        sjqWeightProductionFaeces.setWeightResidue(weightResidue);
        sjqWeightProductionFaeces.setOperator(operator);
        sjqWeightProductionFaeces.setNote(note);

        int result = sjqWeightProductionFaecesMapper.insert(sjqWeightProductionFaeces);
        if (result == 1)
            return true;
        else
            return false;
    }

    @Override
    public boolean addFormKitchen(String date,String startTime,String closeTime,String softNormal,String monitorNormal,String dataNormal,
                           String connectNormal,int train1,double weight1,int train2,double weight2,int trainTotal,
                           double weightTotal,String operator,String note){
        //        String date = DateAndTimeUtil.getDate();
        SjqWeightProductionKitchen sjqWeightProductionKitchen = new SjqWeightProductionKitchen();
        sjqWeightProductionKitchen.setDate(date);
        sjqWeightProductionKitchen.setStartTime(startTime);
        sjqWeightProductionKitchen.setCloseTime(closeTime);
        sjqWeightProductionKitchen.setSoftNormal(softNormal);
        sjqWeightProductionKitchen.setMonitorNormal(monitorNormal);
        sjqWeightProductionKitchen.setDataNormal(dataNormal);
        sjqWeightProductionKitchen.setConnectNormal(connectNormal);
        sjqWeightProductionKitchen.setTrain1(train1);
        sjqWeightProductionKitchen.setWeight1(weight1);
        sjqWeightProductionKitchen.setTrain2(train2);
        sjqWeightProductionKitchen.setWeight2(weight2);
        sjqWeightProductionKitchen.setTrainTotal(trainTotal);
        sjqWeightProductionKitchen.setWeightTotal(weightTotal);
        sjqWeightProductionKitchen.setOperator(operator);
        sjqWeightProductionKitchen.setNote(note);
        int result = sjqWeightProductionKitchenMapper.insert(sjqWeightProductionKitchen);
        if (result == 1)
            return true;
        else
            return false;

    }

    @Override
    public SjqWeightProductionFaeces findFormFaeces(){
        //获取当前日期
        String date = DateAndTimeUtil.getDate();
        System.out.println("当前日期" + date);
        //获取最新记录
        SjqWeightProductionFaeces sjqWeightProductionFaeces = sjqWeightProductionFaecesMapper.findLast();
        System.out.println("最新记录" + sjqWeightProductionFaecesMapper.findLast());
        //获取最新记录日期
        String dateLast =  sjqWeightProductionFaeces.getDate();
        System.out.println("最新记录日期" + dateLast);
        if (date.equals(dateLast))
            return sjqWeightProductionFaeces;
        else
            return null;
    }
    @Override
    public SjqWeightProductionKitchen findFormKitchen(){
        //获取当前日期
        String date = DateAndTimeUtil.getDate();
        System.out.println("当前日期" + date);
        //获取最新记录
        SjqWeightProductionKitchen sjqWeightProductionKitchen = sjqWeightProductionKitchenMapper.findLast();
        System.out.println("最新记录" + sjqWeightProductionKitchenMapper.findLast());
        //获取最新记录日期
        String dateLast =  sjqWeightProductionKitchen.getDate();
        System.out.println("最新记录日期" + dateLast);
        if (date.equals(dateLast))
            return sjqWeightProductionKitchen;
        else
            return null;
    }

    @Override
    public Boolean addFromKitchenExcel(String date, String startTime, String closeTime, String softwareNormal
            , String monitorNormal, String dataNormal, String connectNormal, String operator, String remarks
            , int train1, Double weight1, int train2, Double weight2, int trainTotal, Double weightTotal) {
        SjqWeightProductionKitchen sjqWeightProductionKitchen = new SjqWeightProductionKitchen();
        sjqWeightProductionKitchen.setDate(date);
        sjqWeightProductionKitchen.setStartTime(startTime);
        sjqWeightProductionKitchen.setCloseTime(closeTime);
        sjqWeightProductionKitchen.setSoftNormal(softwareNormal);
        sjqWeightProductionKitchen.setMonitorNormal(monitorNormal);
        sjqWeightProductionKitchen.setDataNormal(dataNormal);
        sjqWeightProductionKitchen.setConnectNormal(connectNormal);
        sjqWeightProductionKitchen.setTrain1(train1);
        sjqWeightProductionKitchen.setWeight1(weight1);
        sjqWeightProductionKitchen.setTrain2(train2);
        sjqWeightProductionKitchen.setWeight2(weight2);
        sjqWeightProductionKitchen.setTrainTotal(trainTotal);
        sjqWeightProductionKitchen.setWeightTotal(weightTotal);
        sjqWeightProductionKitchen.setOperator(operator);
        sjqWeightProductionKitchen.setNote(remarks);
        int result = sjqWeightProductionKitchenMapper.insert(sjqWeightProductionKitchen);
        return result == 1;
    }

    @Override
    public Boolean addFromFaecesExcel(String date, String startTime, String closeTime, String softNormal, String monitorNormal, String dataNormal, String connectNormal, int train1, double weight1, int train2, double weight2, int train3, double weight3, int train4, double weight4, int trainTotal, double weightTotal, int trainResidue, double weightResidue, String operator, String note) {
        SjqWeightProductionFaeces  sjqWeightProductionFaeces = new SjqWeightProductionFaeces();
        sjqWeightProductionFaeces.setDate(date);
        sjqWeightProductionFaeces.setStartTime(startTime);
        sjqWeightProductionFaeces.setCloseTime(closeTime);
        sjqWeightProductionFaeces.setSoftNormal(softNormal);
        sjqWeightProductionFaeces.setMonitorNormal(monitorNormal);
        sjqWeightProductionFaeces.setDataNormal(dataNormal);
        sjqWeightProductionFaeces.setConnectNormal(connectNormal);
        sjqWeightProductionFaeces.setTrain1(train1);
        sjqWeightProductionFaeces.setWeight1(weight1);
        sjqWeightProductionFaeces.setTrain2(train2);
        sjqWeightProductionFaeces.setWeight2(weight2);
        sjqWeightProductionFaeces.setTrain3(train3);
        sjqWeightProductionFaeces.setWeight3(weight3);
        sjqWeightProductionFaeces.setTrain4(train4);
        sjqWeightProductionFaeces.setWeight4(weight4);
        sjqWeightProductionFaeces.setTrainTotal(trainTotal);
        sjqWeightProductionFaeces.setWeightTotal(weightTotal);
        sjqWeightProductionFaeces.setTrainResidue(trainResidue);
        sjqWeightProductionFaeces.setWeightResidue(weightResidue);
        sjqWeightProductionFaeces.setOperator(operator);
        sjqWeightProductionFaeces.setNote(note);

        int result = sjqWeightProductionFaecesMapper.insert(sjqWeightProductionFaeces);
        if (result == 1)
            return true;
        else
            return false;
    }


}
